#define TIMER_IMPLEMENTATION

#include "includes.h"

/****************************************************
 函数名称: TIM2_IRQHandler
 函数作用: 定时器2中断服务函数
 函数参数: 无
 返回值: 无
****************************************************/
void TIM2_IRQHandler(void)
{
    static uint16_t cnt_100ms = 0;
    static uint16_t cnt_500ms = 0;
    static uint16_t cnt_1s = 0;
    static uint16_t cnt_1min = 0;

    // 系统滴答计数
    sysTick++;

    // 时基标志
    cnt_100ms++;
    if (cnt_100ms >= 100)
    {
        cnt_100ms = 0;
        flagTime.is_100ms = TRUE;
        cnt_500ms++;
    }
    if (cnt_500ms >= 5)
    {
        cnt_500ms = 0;
        flagTime.is_500ms = TRUE;
        cnt_1s++;
    }
    if (cnt_1s >= 2)
    {
        cnt_1s = 0;
        flagTime.is_1s = TRUE;
        cnt_1min++;
    }
    if (cnt_1min >= 60)
    {
        cnt_1min = 0;
        flagTime.is_1min = TRUE;
    }

    // 清除标志
    if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
    {
        TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
    }
}

